import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner num = new Scanner(System.in);
        while (num.hasNextInt()) {
            int year = num.nextInt();
            int month = num.nextInt();
            if (month <= 7 && month != 2) {
                if (month % 2 == 1) {
                    System.out.println(31);
                } else if (month % 2 == 0) {
                    System.out.println(30);
                }
            } else if(month == 2){
                if((year % 4 ==0 && year % 100 != 0) || year % 400 == 0){
                    System.out.println(29);
                }else{
                    System.out.println(28);
                }
            } else {
                if (month % 2 == 0) {
                    System.out.println(31);
                } else {
                    System.out.println(30);
                }
            }
        }
    }
}
